﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditSelfData.aspx.cs" Inherits="Student_EditSelfData" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>編輯學生個人資料</title>
    <style type="text/css">

        .style1
        {
            font-family: 微軟正黑體;
            font-size: xx-large;
            text-align: center;
        }
        .style2
        {
            text-align: center;
        }
        .style3
        {
            width: 85%;
        }
        .style4
        {
            color: #FFFF00;
            background-color: #000000;
        }
        .style5
        {
            width: 100%;
        }
        .style6
        {
            color: #FF0000;
        }
        .style7
        {
            border-style: solid;
            border-width: 1px;
            padding: 1px 4px;
        }
        .style8
        {
            color: #00FFFF;
            background-color: #000000;
        }
        .style9
        {
            color: #66FF66;
            background-color: #000000;
        }
        .style10
        {
            color: #00FFFF;
            background-color: #000000;
            height: 20px;
        }
    </style>
     <script type="text/javascript">
         function isDigit(s) {
             var patrn = /^[0-9]{1,20}$/;
             if (!patrn.exec(s)) {
                 alert('请输入数字');
                 return false;
             }
             return true
         } 
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="style2">
    
        <span class="style1">編輯學生個人資料</span><br />
        <br />
        目前身分：<asp:Label ID="Label1" runat="server"></asp:Label>
        <br />
        <br />
        <table align="center" class="style3">
            <tr>
                <td class="style4" colspan="2">
                    編輯個人資料：</td>
            </tr>
            <tr>
                <td colspan="2">
                    <br />
                    <asp:FormView ID="FormView1" runat="server" DataKeyNames="StudentId" 
                        DataSourceID="SqlDataSource1">
                        <EditItemTemplate>
                            <table class="style5">
                                <tr>
                                    <td colspan="2">
                                        在此僅能修改 電子信箱、自我介紹等兩個項目<br /> 
                                        <br />
                                        如需更改其他資料 請洽 相關人員<br /> </td>
                                </tr>
                                <tr>
                                    <td>
                                        電子信箱：</td>
                                    <td>
                                        <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                    <td>
                                        &nbsp;</td>
                                </tr>
                                <tr>
                                    <td>
                                        自我介紹：</td>
                                    <td>
                                        <asp:TextBox ID="SelfIntroTextBox" runat="server" Height="74px" MaxLength="200" 
                                            Text='<%# Bind("SelfIntro") %>' TextMode="MultiLine" Width="295px" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                    <td class="style6">
                                        (限兩百字)</td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                    <td>
                                        &nbsp;</td>
                                </tr>
                            </table>
                            <br />
                            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                                CommandName="Update" Text="更新" />
                            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                                CausesValidation="False" CommandName="Cancel" Text="取消" />
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            StudentId:
                            <asp:TextBox ID="StudentIdTextBox" runat="server" 
                                Text='<%# Bind("StudentId") %>' />
                            <br />
                            StudentName:
                            <asp:TextBox ID="StudentNameTextBox" runat="server" 
                                Text='<%# Bind("StudentName") %>' />
                            <br />
                            Birth:
                            <asp:TextBox ID="BirthTextBox" runat="server" Text='<%# Bind("Birth") %>' />
                            <br />
                            Email:
                            <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
                            <br />
                            Gender:
                            <asp:TextBox ID="GenderTextBox" runat="server" Text='<%# Bind("Gender") %>' />
                            <br />
                            SelfIntro:
                            <asp:TextBox ID="SelfIntroTextBox" runat="server" 
                                Text='<%# Bind("SelfIntro") %>' />
                            <br />
                            Address:
                            <asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
                            <br />
                            SSN:
                            <asp:TextBox ID="SSNTextBox" runat="server" Text='<%# Bind("SSN") %>' />
                            <br />
                            DepartmentId:
                            <asp:TextBox ID="DepartmentIdTextBox" runat="server" 
                                Text='<%# Bind("DepartmentId") %>' />
                            <br />
                            DepartmentName:
                            <asp:TextBox ID="DepartmentNameTextBox" runat="server" 
                                Text='<%# Bind("DepartmentName") %>' />
                            <br />
                            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                                CommandName="Insert" Text="插入" />
                            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                                CausesValidation="False" CommandName="Cancel" Text="取消" />
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <table class="style5">
                                <tr>
                                    <td class="style7">
                                        學生證號：</td>
                                    <td class="style7">
                                        <asp:Label ID="StudentIdLabel" runat="server" Text='<%# Eval("StudentId") %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="style7">
                                        系別：</td>
                                    <td class="style7">
                                        <asp:Label ID="DepartmentNameLabel" runat="server" 
                                            Text='<%# Bind("DepartmentName") %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="style7">
                                        姓名：</td>
                                    <td class="style7">
                                        <asp:Label ID="StudentNameLabel" runat="server" 
                                            Text='<%# Bind("StudentName") %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="style7">
                                        出生日期：</td>
                                    <td class="style7">
                                        <asp:Label ID="BirthLabel" runat="server" Text='<%# Bind("Birth") %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="style7">
                                        性別：</td>
                                    <td class="style7">
                                        <asp:Label ID="GenderLabel" runat="server" Text='<%# Bind("Gender") %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="style7">
                                        身分證號：</td>
                                    <td class="style7">
                                        <asp:Label ID="SSNLabel" runat="server" Text='<%# Bind("SSN") %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="style7">
                                        電子信箱：</td>
                                    <td class="style7">
                                        <asp:Label ID="EmailLabel" runat="server" Text='<%# Bind("Email") %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="style7">
                                        地址：</td>
                                    <td class="style7">
                                        <asp:Label ID="AddressLabel" runat="server" Text='<%# Bind("Address") %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="style7">
                                        &nbsp;</td>
                                    <td class="style7">
                                        &nbsp;</td>
                                </tr>
                                <tr>
                                    <td class="style7">
                                        自我介紹：</td>
                                    <td class="style7">
                                        <asp:TextBox ID="TextBox1" runat="server" Height="179px" ReadOnly="True" 
                                            Text='<%# Bind("SelfIntro", "{0}") %>' TextMode="MultiLine" Width="294px"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                    <td>
                                        &nbsp;</td>
                                </tr>
                            </table>
                            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                                CommandName="Edit" Text="編輯" />
                            &nbsp;&nbsp;
                        </ItemTemplate>
                    </asp:FormView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>" 
            DeleteCommand="DELETE FROM [Student] WHERE [StudentId] = @StudentId" 
            InsertCommand="INSERT INTO [Student] ([StudentId], [StudentName], [Birth], [Email], [Gender], [SelfIntro], [Address], [SSN], [DepartmentId]) VALUES (@StudentId, @StudentName, @Birth, @Email, @Gender, @SelfIntro, @Address, @SSN, @DepartmentId)" 
            SelectCommand="SELECT Student.StudentId, Student.StudentName, Student.Birth, Student.Email, Student.Gender, Student.SelfIntro, Student.Address, Student.SSN, Student.DepartmentId, Department.DepartmentName FROM Student INNER JOIN Department ON Student.DepartmentId = Department.DepartmentId WHERE (Student.StudentId = @StudentId)" 
            UpdateCommand="UPDATE [Student] SET [StudentName] = @StudentName, [Birth] = @Birth, [Email] = @Email, [Gender] = @Gender, [SelfIntro] = @SelfIntro, [Address] = @Address, [SSN] = @SSN, [DepartmentId] = @DepartmentId WHERE [StudentId] = @StudentId">
            <DeleteParameters>
                <asp:Parameter Name="StudentId" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="StudentId" Type="Int32" />
                <asp:Parameter Name="StudentName" Type="String" />
                <asp:Parameter DbType="Date" Name="Birth" />
                <asp:Parameter Name="Email" Type="String" />
                <asp:Parameter Name="Gender" Type="String" />
                <asp:Parameter Name="SelfIntro" Type="String" />
                <asp:Parameter Name="Address" Type="String" />
                <asp:Parameter Name="SSN" Type="String" />
                <asp:Parameter Name="DepartmentId" Type="Int32" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="Label1" Name="StudentId" PropertyName="Text" 
                    Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="StudentName" Type="String" />
                <asp:Parameter DbType="Date" Name="Birth" />
                <asp:Parameter Name="Email" Type="String" />
                <asp:Parameter Name="Gender" Type="String" />
                <asp:Parameter Name="SelfIntro" Type="String" />
                <asp:Parameter Name="Address" Type="String" />
                <asp:Parameter Name="SSN" Type="String" />
                <asp:Parameter Name="DepartmentId" Type="Int32" />
                <asp:Parameter Name="StudentId" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    
                </td>
            </tr>
            <tr>
                <td class="style9">
                    編輯電話資料</td>
                <td class="style8">
                    編輯手機資料</td>
            </tr>
            <tr>
                <td>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                        ControlToValidate="TextBox2" ErrorMessage="RegularExpressionValidator" 
                        ValidationExpression="^[0-9]{1,20}$" style="color: #FF0000" 
                        ValidationGroup="phone">僅限數字</asp:RegularExpressionValidator>
                </td>
                <td>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                        ControlToValidate="TextBox3" ErrorMessage="RegularExpressionValidator" 
                        ValidationExpression="^[0-9]{1,20}$" style="color: #FF0000" 
                        ValidationGroup="cellphone">僅限數字</asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server" ValidationGroup="phone"></asp:TextBox>
&nbsp;<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="新增電話" 
                        ValidationGroup="phone" />
                </td>
                <td>
                    <asp:TextBox ID="TextBox3" runat="server" ValidationGroup="cellphone"></asp:TextBox>
&nbsp;<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="新增手機" 
                        ValidationGroup="cellphone" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                        BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" 
                        CellPadding="4" DataKeyNames="serial" DataSourceID="SqlDataSource2" 
                        Width="220px">
                        <Columns>
                            <asp:BoundField DataField="serial" HeaderText="serial" InsertVisible="False" 
                                ReadOnly="True" SortExpression="serial" Visible="False" />
                            <asp:BoundField DataField="StudentId" HeaderText="StudentId" 
                                SortExpression="StudentId" Visible="False" />
                            <asp:BoundField DataField="Phone" HeaderText="電話" SortExpression="Phone" />
                            <asp:CommandField ButtonType="Button" ShowDeleteButton="True" 
                                ShowEditButton="True" />
                        </Columns>
                        <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
                        <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
                        <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
                        <RowStyle BackColor="White" ForeColor="#330099" />
                        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
                        <SortedAscendingCellStyle BackColor="#FEFCEB" />
                        <SortedAscendingHeaderStyle BackColor="#AF0101" />
                        <SortedDescendingCellStyle BackColor="#F6F0C0" />
                        <SortedDescendingHeaderStyle BackColor="#7E0000" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>" 
                        DeleteCommand="DELETE FROM [StudentPhone] WHERE [serial] = @serial" 
                        InsertCommand="INSERT INTO [StudentPhone] ([StudentId], [Phone]) VALUES (@StudentId, @Phone)" 
                        SelectCommand="SELECT * FROM [StudentPhone] WHERE ([StudentId] = @StudentId)" 
                        
                        
                        UpdateCommand="UPDATE [StudentPhone] SET [StudentId] = @StudentId, [Phone] = @Phone WHERE [serial] = @serial">
                        <DeleteParameters>
                            <asp:Parameter Name="serial" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:ControlParameter ControlID="Label1" Name="StudentId" PropertyName="Text" 
                                Type="Int32" />
                            <asp:ControlParameter ControlID="TextBox2" Name="Phone" PropertyName="Text" 
                                Type="String" />
                        </InsertParameters>
                        <SelectParameters>
                            <asp:ControlParameter ControlID="Label1" Name="StudentId" PropertyName="Text" 
                                Type="Int32" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:ControlParameter ControlID="Label1" Name="StudentId" PropertyName="Text" 
                                Type="Int32" />
                            <asp:Parameter Name="Phone" Type="String" />
                            <asp:Parameter Name="serial" Type="Int32" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
                </td>
                <td>
                    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                        CellPadding="4" DataKeyNames="serial" DataSourceID="SqlDataSource3" 
                        ForeColor="#333333" GridLines="None" Width="218px">
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                            <asp:BoundField DataField="serial" HeaderText="serial" 
                                SortExpression="serial" InsertVisible="False" ReadOnly="True" 
                                Visible="False" />
                            <asp:BoundField DataField="StudentId" HeaderText="StudentId" 
                                SortExpression="StudentId" Visible="False" />
                            <asp:BoundField DataField="CellPhone" HeaderText="手機號碼" 
                                SortExpression="CellPhone" />
                            <asp:CommandField ButtonType="Button" ShowDeleteButton="True" 
                                ShowEditButton="True" />
                        </Columns>
                        <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
                        <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                        <SortedAscendingCellStyle BackColor="#FDF5AC" />
                        <SortedAscendingHeaderStyle BackColor="#4D0000" />
                        <SortedDescendingCellStyle BackColor="#FCF6C0" />
                        <SortedDescendingHeaderStyle BackColor="#820000" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>" 
                        DeleteCommand="DELETE FROM [StudentCellPhone] WHERE [serial] = @serial" 
                        InsertCommand="INSERT INTO [StudentCellPhone] ([StudentId], [CellPhone]) VALUES (@StudentId, @CellPhone)" 
                        SelectCommand="SELECT * FROM [StudentCellPhone] WHERE ([StudentId] = @StudentId)" 
                        
                        
                        UpdateCommand="UPDATE [StudentCellPhone] SET [StudentId] = @StudentId, [CellPhone] = @CellPhone WHERE [serial] = @serial">
                        <DeleteParameters>
                            <asp:Parameter Name="serial" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:ControlParameter ControlID="Label1" Name="StudentId" PropertyName="Text" 
                                Type="Int32" />
                            <asp:ControlParameter ControlID="TextBox3" Name="CellPhone" PropertyName="Text" 
                                Type="String" />
                        </InsertParameters>
                        <SelectParameters>
                            <asp:ControlParameter ControlID="Label1" Name="StudentId" PropertyName="Text" 
                                Type="Int32" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:ControlParameter ControlID="Label1" Name="StudentId" PropertyName="Text" 
                                Type="Int32" />
                            <asp:Parameter Name="CellPhone" Type="String" />
                            <asp:Parameter Name="serial" Type="Int32" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style4" colspan="2">
                    新增參與活動資料</td>
            </tr>
            <tr>
                <td>
                    <table class="style5">
                        <tr>
                            <td rowspan="2">
                                活動名稱：</td>
                            <td>
                                <asp:TextBox ID="TextBox4" runat="server" Height="60px" TextMode="MultiLine" 
                                    Width="150px" ValidationGroup="down"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                    ControlToValidate="TextBox4" CssClass="style6" 
                                    ErrorMessage="RequiredFieldValidator" ValidationGroup="down">請輸入名稱</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td rowspan="2">
                                概述介紹：<br />
                                (以100字為限)</td>
                            <td>
                                <asp:TextBox ID="TextBox5" runat="server" Height="68px" TextMode="MultiLine" 
                                    Width="150px" ValidationGroup="down"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                    ControlToValidate="TextBox5" CssClass="style6" 
                                    ErrorMessage="RequiredFieldValidator" ValidationGroup="down">請輸入介紹</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td rowspan="2">
                                時間：</td>
                            <td>
                                <asp:TextBox ID="TextBox6" runat="server" Width="149px" Height="19px" 
                                    ValidationGroup="down"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                    ControlToValidate="TextBox6" CssClass="style6" 
                                    ErrorMessage="RequiredFieldValidator" ValidationGroup="down">請輸入日期</asp:RequiredFieldValidator>
                                <br />
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
                        ControlToValidate="TextBox6" ErrorMessage="RegularExpressionValidator" 
                        
                                    ValidationExpression="(19|20)[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])" 
                                    style="color: #FF0000" ValidationGroup="down">請輸入正確日期格式</asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;</td>
                            <td>
                                <asp:Button ID="Button5" runat="server" onclick="Button5_Click" Text="新增" 
                                    ValidationGroup="down" />
&nbsp;<asp:Button ID="Button6" runat="server" onclick="Button6_Click" Text="取消" />
                                <asp:SqlDataSource ID="SqlDataSource5" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>" 
                                    InsertCommand="INSERT INTO Activity(Intro, StudentId, ArtivityName, Time) VALUES (@intro, @id, @name, @time)" 
                                    SelectCommand="SELECT * FROM [Activity]">
                                    <InsertParameters>
                                        <asp:ControlParameter ControlID="TextBox5" Name="intro" PropertyName="Text" />
                                        <asp:ControlParameter ControlID="Label1" Name="id" PropertyName="Text" />
                                        <asp:ControlParameter ControlID="TextBox4" Name="name" PropertyName="Text" />
                                        <asp:ControlParameter ControlID="TextBox6" Name="time" PropertyName="Text" />
                                    </InsertParameters>
                                </asp:SqlDataSource>
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <br />
                    <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" 
                        BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" 
                        CellPadding="4" DataSourceID="SqlDataSource4" 
                        onselectedindexchanged="GridView3_SelectedIndexChanged" Width="342px" 
                        DataKeyNames="serial">
                        <Columns>
                            <asp:BoundField DataField="serial" HeaderText="serial" InsertVisible="False" 
                                ReadOnly="True" SortExpression="serial" Visible="False" />
                            <asp:BoundField DataField="StudentId" HeaderText="StudentId" 
                                SortExpression="StudentId" Visible="False" />
                            <asp:BoundField DataField="ArtivityName" HeaderText="活動名稱" 
                                SortExpression="ArtivityName" />
                            <asp:TemplateField HeaderText="時間" SortExpression="Time">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Time", "{0:d}") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Time", "{0:d}") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="Intro" HeaderText="介紹" 
                                SortExpression="Intro" />
                            <asp:CommandField ButtonType="Button" ShowDeleteButton="True" 
                                ShowEditButton="True" />
                        </Columns>
                        <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                        <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
                        <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                        <RowStyle BackColor="White" ForeColor="#003399" />
                        <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                        <SortedAscendingCellStyle BackColor="#EDF6F6" />
                        <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                        <SortedDescendingCellStyle BackColor="#D6DFDF" />
                        <SortedDescendingHeaderStyle BackColor="#002876" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>" 
                        SelectCommand="SELECT * FROM [Activity] WHERE ([StudentId] = @StudentId)" 
                        
                        UpdateCommand="UPDATE [Activity] SET [StudentId] = @StudentId, [Intro] = @Intro, [ArtivityName] = @ArtivityName, [Time] = @Time WHERE [serial] = @serial" 
                        DeleteCommand="DELETE FROM [Activity] WHERE [serial] = @serial" 
                        InsertCommand="INSERT INTO [Activity] ([StudentId], [Intro], [ArtivityName], [Time]) VALUES (@StudentId, @Intro, @ArtivityName, @Time)">
                        <DeleteParameters>
                            <asp:Parameter Name="serial" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="StudentId" Type="Int32" />
                            <asp:Parameter Name="Intro" Type="String" />
                            <asp:Parameter Name="ArtivityName" Type="String" />
                            <asp:Parameter DbType="Date" Name="Time" />
                        </InsertParameters>
                        <SelectParameters>
                            <asp:ControlParameter ControlID="Label1" Name="StudentId" PropertyName="Text" 
                                Type="Int32" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:ControlParameter ControlID="Label1" Name="StudentId" PropertyName="Text" 
                                Type="Int32" />
                            <asp:Parameter Name="Intro" Type="String" />
                            <asp:Parameter Name="ArtivityName" Type="String" />
                            <asp:Parameter Name="Time" DbType="Date" />
                            <asp:Parameter Name="serial" Type="Int32" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td class="style10" colspan="2">
                    新增證書資料</td>
            </tr>
            <tr>
                <td>
                    <table class="style5">
                        <tr>
                            <td rowspan="2">
                                證書名稱：</td>
                            <td>
                                <asp:TextBox ID="TextBox7" runat="server" Height="60px" TextMode="MultiLine" 
                                    Width="150px" ValidationGroup="sec"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                                    ControlToValidate="TextBox7" CssClass="style6" 
                                    ErrorMessage="RequiredFieldValidator" ValidationGroup="sec">請輸入名稱</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td rowspan="2">
                                概述介紹：<br />
                                (以100字為限)</td>
                            <td>
                                <asp:TextBox ID="TextBox8" runat="server" Height="68px" TextMode="MultiLine" 
                                    Width="150px" ValidationGroup="sec"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                                    ControlToValidate="TextBox8" CssClass="style6" 
                                    ErrorMessage="RequiredFieldValidator" ValidationGroup="sec">請輸入介紹</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td rowspan="2">
                                取得時間：</td>
                            <td>
                                <asp:TextBox ID="TextBox9" runat="server" Width="149px" Height="19px" 
                                    ValidationGroup="sec"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                                    ControlToValidate="TextBox9" CssClass="style6" 
                                    ErrorMessage="RequiredFieldValidator" ValidationGroup="sec">請輸入日期</asp:RequiredFieldValidator>
                                <br />
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" 
                        ControlToValidate="TextBox9" ErrorMessage="RegularExpressionValidator" 
                        
                                    ValidationExpression="(19|20)[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])" 
                                    style="color: #FF0000" ValidationGroup="sec">請輸入正確日期格式</asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;</td>
                            <td>
                                <asp:Button ID="Button8" runat="server" onclick="Button8_Click" Text="新增" 
                                    ValidationGroup="sec" />
&nbsp;<asp:Button ID="Button9" runat="server" onclick="Button9_Click" Text="取消" />
                                <asp:SqlDataSource ID="SqlDataSource6" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>" 
                                    InsertCommand="INSERT INTO Certificate(StudentId, CertificateName, Time, Intro) VALUES (@StudentId, @CertificateName, @Time, @Intro)" 
                                    SelectCommand="SELECT StudentId AS Expr1, CertificateName AS Expr2, Time AS Expr3, Intro AS Expr4 FROM Certificate">
                                    <InsertParameters>
                                        <asp:ControlParameter ControlID="Label1" Name="StudentId" PropertyName="Text" />
                                        <asp:ControlParameter ControlID="TextBox7" Name="CertificateName" 
                                            PropertyName="Text" />
                                        <asp:ControlParameter ControlID="TextBox9" Name="Time" PropertyName="Text" />
                                        <asp:ControlParameter ControlID="TextBox8" Name="Intro" PropertyName="Text" />
                                    </InsertParameters>
                                </asp:SqlDataSource>
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <asp:GridView ID="GridView4" runat="server" AutoGenerateColumns="False" 
                        CellPadding="4" DataKeyNames="serial" DataSourceID="SqlDataSource7" 
                        ForeColor="#333333" GridLines="None" 
                        onselectedindexchanged="GridView4_SelectedIndexChanged">
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                            <asp:BoundField DataField="serial" HeaderText="serial" InsertVisible="False" 
                                ReadOnly="True" SortExpression="serial" Visible="False" />
                            <asp:BoundField DataField="StudentId" HeaderText="StudentId" 
                                SortExpression="StudentId" Visible="False" />
                            <asp:BoundField DataField="CertificateName" HeaderText="CertificateName" 
                                SortExpression="CertificateName" />
                            <asp:TemplateField HeaderText="Time" SortExpression="Time">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Time", "{0:d}") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Time", "{0:d}") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="Intro" HeaderText="Intro" SortExpression="Intro" />
                            <asp:CommandField ButtonType="Button" ShowDeleteButton="True" 
                                ShowEditButton="True" />
                        </Columns>
                        <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
                        <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                        <SortedAscendingCellStyle BackColor="#FDF5AC" />
                        <SortedAscendingHeaderStyle BackColor="#4D0000" />
                        <SortedDescendingCellStyle BackColor="#FCF6C0" />
                        <SortedDescendingHeaderStyle BackColor="#820000" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="SqlDataSource7" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>" 
                        DeleteCommand="DELETE FROM [Certificate] WHERE [serial] = @serial" 
                        InsertCommand="INSERT INTO [Certificate] ([StudentId], [CertificateName], [Time], [Intro]) VALUES (@StudentId, @CertificateName, @Time, @Intro)" 
                        SelectCommand="SELECT * FROM [Certificate] WHERE ([StudentId] = @StudentId)" 
                        UpdateCommand="UPDATE [Certificate] SET [StudentId] = @StudentId, [CertificateName] = @CertificateName, [Time] = @Time, [Intro] = @Intro WHERE [serial] = @serial">
                        <DeleteParameters>
                            <asp:Parameter Name="serial" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="StudentId" Type="Int32" />
                            <asp:Parameter Name="CertificateName" Type="String" />
                            <asp:Parameter DbType="Date" Name="Time" />
                            <asp:Parameter Name="Intro" Type="String" />
                        </InsertParameters>
                        <SelectParameters>
                            <asp:ControlParameter ControlID="Label1" Name="StudentId" PropertyName="Text" 
                                Type="Int32" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:ControlParameter ControlID="Label1" Name="StudentId" PropertyName="Text" 
                                Type="Int32" />
                            <asp:Parameter Name="CertificateName" Type="String" />
                            <asp:Parameter DbType="Date" Name="Time" />
                            <asp:Parameter Name="Intro" Type="String" />
                            <asp:Parameter Name="serial" Type="Int32" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    &nbsp;</td>
            </tr>
            <tr>
                <td colspan="2">
                    &nbsp;</td>
            </tr>
        </table>
        <br />
        <br />
    
    </div>
    </form>
</body>
</html>
